local Obj = require("core.Obj")
local ObjHuman = require("core.ObjHuman")
local BagLogic = require("bag.BagLogic")
local Wushuang = require("copy.Wushuang")
local ItemDefine = require("bag.ItemDefine")
local CopyL = require("copy.CopyL")

function handler(obj, config)--, copyID)
	if obj.obj_type~=Obj.TYPE_HUMAN then return true end
	
	for _,loss in ipairs(config.enterLoss) do
		local callback = _ENV[loss[1]]
		if not callback(obj,loss[2],loss[3],loss[4]) then	--人物
			return
		end
	end
	
	return true
end

--***************条件****************

function yinliang(obj,value)
	local currentValue = ObjHuman.getYinliang(obj)
	if currentValue>=value then
		ObjHuman.decYinliang(obj, value, "enter_copy")
		return true
	end
end

function item(obj,itemID,count)	
  if itemID == ItemDefine.ITEM_ID_XUBAO_ITEM then
      count = CopyL.getXunbaoCostCnt(obj)
  end
	if BagLogic.getItemCount(obj,itemID)>=count then
		return BagLogic.delItemsById(obj,itemID,count,"enter_copy")
	end
end

function tiaozhanval(obj, value)
  local currentValue = obj.db.remainTZ
  if currentValue >= value then
    obj.db.remainTZ = obj.db.remainTZ - value
    Wushuang.sendTZTimes(obj)
    return true
  end
end

